import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';
import 'package:largefriends/pages/lf_forget_password/lf_forget_password_logic.dart';
import 'package:largefriends/res/lf_color.dart';
import 'package:largefriends/res/lf_double_ext.dart';
import 'package:largefriends/res/lf_fonts.dart';
import 'package:largefriends/res/lf_text_style.dart';
import 'package:largefriends/res/strings/lf_strings.dart';
import 'package:largefriends/widgets/lf_app_bar.dart';
import 'package:largefriends/widgets/lf_button.dart';

import '../../widgets/lf_auto_complete.dart';

class LfForgetPasswordPage extends StatefulWidget {
  const LfForgetPasswordPage({super.key});

  @override
  State<LfForgetPasswordPage> createState() => _LfForgetPasswordPageState();
}

class _LfForgetPasswordPageState extends State<LfForgetPasswordPage> {
  final logic = Get.put(LfForgetPasswordLogic());
  @override
  Widget build(BuildContext context) {
    return WillPopScope(
      child: Scaffold(
        appBar: lfAppBar(
          title: strForgotPasswordTitle.tr,
          leadingCallback: () {
            Get.back();
          },
        ),
        body: Stack(
          children: [
            Positioned.fill(
                child: Padding(
              padding: EdgeInsets.symmetric(horizontal: 16.w),
              child: CustomScrollView(
                slivers: [
                  20.h.sliverBox,
                  autoCompleteWidget(
                          onSelected: (String value) {
                            logic.email.value = value;
                          },
                          hintText: strYourEmail.tr,
                          focusNode: logic.focusNode,
                          enable: logic.canInputEmail.value,
                          onChanged: (String value) {
                            logic.email.value = value;
                          },
                          controller: logic.emailController)
                      .sliverBox,
                  20.h.sliverBox,
                  Text(
                    strSendLinkTip.tr,
                    style: lfTextStyle(
                        sp: 16.sp, fontFamily: fontMedium),
                  ).sliverBox,
                  30.h.sliverBox,
                  Obx(() {
                    return LfButton(
                        enabled: logic.email.value.isEmail,
                        text: strConfirm.tr,
                        onPress: () {
                          logic.forgetPassword();
                        });
                  }).sliverBox
                ],
              ),
            )),
          ],
        ),
      ),
      onWillPop: () async {
        Get.back();
        return false;
      },
    );
  }
}
